A sparse file is one that has small regions that have been written and the remainder of the file is not written. Holes in a sparse file are thus regions of the file that have not been written but have an offset value that is lower than the largest valid offset in the file. Most file systems do not actually save the “holes” on storage but rather save a more compact amount of metadata describing how the file is sparse.
Most modern file systems support sparse files by attempting to use file system space more efficiently when blocks allocated to the sparse file are mostly empty. For example, some file systems write brief information (metadata) representing the empty blocks to the disk instead of the actual “empty” space that makes up the block, thereby using less disk space. Typically, however, existing file systems will process sparse file at the granularity of a file system block, which is typically a value of 4096 bytes. When reading sparse files, the file system transparently converts metadata representing empty blocks into “real” blocks filled with zero bytes at runtime.
A need therefore exists for improved techniques for storing sparse files in a file system.